AddElement
Adds a paragraph or a table or a blockLvl content control using its position in the cell.
Syntax
expression.AddElement(nPos, oElement);
expression
- A variable that represents a ApiTableCell class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
nPos | Required | number | The position where the current element will be added. | |
oElement | Required | DocumentElement | The document element which will be added at the current position. |
Returns
boolean
Example
This example adds a paragraph using its position in the cell.
let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let paragraph = Api.CreateParagraph();
paragraph.AddText("This is just a sample text in the first cell.");
let cell = table.GetCell(0, 0);
cell.AddElement(0, paragraph);